package org.lpw.wormhole.queue;

import java.util.HashMap;
import java.util.Map;

import org.lpw.wormhole.element.Element;
import org.lpw.wormhole.util.Kit;

/**
 * @author lpw
 */
public class RemoteQueueImpl
    implements RemoteQueue
{
    private static final String ELEMENT = "element";

    protected final Kit kit;

    public RemoteQueueImpl(Kit kit)
    {
        this.kit = kit;
    }

    @Override
    public void push(Element element)
    {
        if(element==null||kit.getConfigurer().getRemoteQueueUrl().length==0)
            return;

        Map<String, String> params = new HashMap<String, String>();
        params.put(ELEMENT, kit.getConverter().serializeToHexString(element));
        kit.getHttp().put(kit.getConfigurer().getRemoteQueueUrl(), params);
    }
}
